package network;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Scanner;

public class Client {
    public static void main(String[] args) {
        String hostname = "localhost";
        int port = 1080;
        Scanner entry = new Scanner(System.in);
        try {
            Socket client = new Socket(hostname, port);
            PrintWriter out = new PrintWriter(client.getOutputStream(), true);
            BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
            String data;
            System.out.print("Input some message: ");
            while (!"exit".equals(data = entry.nextLine())) {
                out.println(data);
                System.out.println("Receive server reply: " + in.readLine());
                System.out.print("Input some message: ");
            }
            entry.close();
            client.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
